<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php
	require("wwdb.php");
	$username = cleanparam("username");
?>
<meta name="viewport" content="width=device-width, initial-scale=0.75, maximum-scale=1.2, minimum-scale=0.75, user-scalable=yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<meta name="apple-mobile-web-app-capable" content="yes" />	
<link rel="stylesheet" type="text/css" href="WW.css" />
<title>Word Waffle - Leaderboards</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script src="iPhoneFriendly.js" type="text/javascript"></script>
</head>
<body>
<div id="page" style="width:100%;text-align:center">
	<div id="container" style="text-align:left;width:440px">
		<?php require "banner.htm"; ?>
		<h1 style="font-variant:small-caps;text-align:center">Leaderboard</h1>
		<ul>
			<?php
			if ($username != null) {
				echo "<li id='user' title='$username'>";
				echo "<span class='fakeLink'>User Stats [$username]</span>";
				echo "<div class='board' title='userStats'></div></li><br />";
			}
			?>
			<span style="font-size:20px">High Scores</span>
			<?php
				for ($i=1;$i<6;$i++) {
					echo "<li><span class='fakeLink'>$i-player game</span>";
					echo "<div class='board' title='highp$i'></div></li>";
				}
			?>
			<br />
			<li>
				<span class="fakeLink">Top Waffles</span>
				<div class="board" title="topWaffles" style="width:438px;padding:0px;left:-40px" />
			</li>

			<li>
				<span class="fakeLink">Letter Frequency</span>
				<div class="board" title="letterFrequency" />
			</li>
		</ul>
		<br />
	</div>
</div>
<script type="text/javascript">
$("li").click(function(){
	$(this).children("div").toggle();
	if ($(this).children("div").html() == "") {
		$(this).children("div").html("Loading...");
		var username = $("#user").attr("title");
		$.ajax({
			url:"stats.php",
			context: $(this).children("div"),
			data:"j=" + $(this).children("div").attr("title") + "&username=" + username,
			success:function(results) {$(this).html(results);},
			error:function(results) {$(this).html("Error");}
		});
	}
});
</script>
</body>
</html>